function [ tdrop ] = calcBomberTime(pj,n )
% Function calculates, when the bomb should be dropped, under the condition
% that the ship is alternating between A and B; tdrop defines after how many switches between A and B the drop should be dropped. 


%Select tdrop
rn=rand(1,1);
for i=1:length(pj)
    tmp=((n^2+1)*(sum(pj(1:i))) - (n^2)*pj(1));
    if(rn<= tmp)
       tdrop=(i-1);
       break
    end
end


end

